﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;

namespace SubstrateHelper.Models
{
    public class SubstrateInfo:ProcessBase.Models.CopyFromBase<SubstrateInfo>
    {
       

        public int ID { get; set; }
        
        [DisplayName ("溅射批号")]
        public string LotNo { get; set; }

        [DisplayName ("片号")]
        public int PartNo { get; set; }

        [DisplayName ("厚度")]
        public double Thickness { get; set; }

        [DisplayName ("K值")]
        public double K_avg { get; set; }

        //[DisplayName ("K值最大")]
        //public double K_max { get; set; }

        //[DisplayName ("K值最小")]
        //public double K_min { get; set; }

        //[DisplayName ("损耗平均")]
        //public double DF_avg { get; set; }

        [DisplayName ("损耗")]
        public double DF_max { get; set; }


        //[DisplayName ("损耗最小")]
        //public double DF_min { get; set; }


        //[DisplayName ("工作电压平均")]
        //public double WorkV_avg { get; set; }

        //[DisplayName ("工作电压可至")]
        //public double WorkV_max { get; set; }


        //[DisplayName ("工作电压满足")]
        //public double WorkV_min { get; set; }


        [DisplayName ("比容")]
        public double CPA { get; set; }


        [DisplayName ("容量极差")]
        public double ErrorC { get; set; }


        [DisplayName ("入库日期")]
        public DateTime UploadingDate { get; set; }


        [DisplayName ("排产日期")]
        public DateTime? SchedulingDate { get; set; }


        [DisplayName ("排产批号")]
        public string ScheduledLotNo { get; set; }


        [DisplayName ("排产人")]
        public string Scheduler { get; set; }

        [DisplayName ("掩膜版")]
        public string Mask { get; set; }

        [DisplayName("设计长度")]
        public double? CuttingL { get; set; }

        [DisplayName("设计宽度")]
        public double? CuttingW { get; set; }


        [DisplayName ("镀金类型")]
        public string PlatedType { get; set; }

        [DisplayName ("备注")]
        public string Memo { get; set; }

        [DisplayName("设计误差")]
        public double? DesignError { get; set; }

        public void CalculateDesignError(double? cpaMid)
        {
            if (cpaMid!=null && cpaMid > 0)
            {
                DesignError =Math.Abs((CPA - cpaMid.Value) / cpaMid.Value);
            }            
        }

        [DisplayName("裸基板批号")]
        public string NakedLotNo { get; set; }

        [DisplayName("排产特殊要求")]
        public string ScheduleMemo { get; set; }

        [DisplayName("材料型号")]
        public string SubstrateMaterialType { get; set; }

        [DisplayName("电容型号")]
        public string SchedulingType { get; set; }

        [DisplayName("耐压")]
        public double BDV { get; set; }

        [DisplayName("基板类型")]
        public string SubstrateType { get; set; }

        [DisplayName("已入NC库")]
        public bool OutputToNC { get; set; }

        

        public static List<SubstrateInfo> CopyList(List<SubstrateInfo> substrateInfos)
        {
            List<SubstrateInfo> infos = new List<SubstrateInfo>();
            foreach(var info in substrateInfos)
            {
                infos.Add(info.MemberwiseClone() as SubstrateInfo);
            }

            return infos;
        }

    }
}
